<?php 
  include("../inc/global.inc"); 

 	function chkCode(){
		if($_SESSION['chkCode']!=$_POST["chkCode"]){
			echo"<script>alert('验证码错误');location=location</script>"; return false;
		}
		return true;
	}
		if($_POST["userID"]){
	   if(!chkCode()) exit;
		$rs = mysql_query("select * from admin where admin_cname='".$_POST['userID']."' and admin_sys=1");
		$row = @mysql_fetch_row($rs);
		//print_r($row);exit;
		if($row[1]){
			if($row[2]==substr(md5($_POST["password"]),6,18)){
				$_SESSION['admin_user']=$row[1];
				$_SESSION['admin_dj']=$row[5];
				$_SESSION[admin_sys]=$row[4];
				mysql_query("update admin set login_time='".date("Y-m-d H:i:s")."' where id='$row[0]'");
				echo"<script>parent.location=parent.location</script>"; exit;
			}else{
				echo"<script>alert('密码错误');parent.location=parent.location</script>"; exit;
			}
		}else{
			echo"<script>alert('用户名错误');parent.location=parent.location</script>"; exit;
		}
	}
if ($_GET[out]==1){
unset($_SESSION['admin_user']);
}
?>
<HTML>
<HEAD>
<TITLE>三帝贸易网管理后台</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="css/css.css" rel=stylesheet>
<script type='text/javascript' src="js/outlook_bar.js"></script>
<script type='text/javascript' src="js/admin.js"></script>
<style type="text/css">
body {
	background-repeat: no-repeat;
	background-color: #9CDCF9;
	background-position: 0px 0px;

}
</style>
</HEAD>
<BODY scroll="auto" style=" MARGIN: 0px;">
<?php 
	if ($_SESSION['admin_user']){
	$left_url=($_SESSION['admin_dj']==1)?"left.php":"left2.php";
	$right_url=($_SESSION['admin_dj']==1)?"right.php":"right.php";

?>
<table border="0" cellPadding="0" cellSpacing="0" height="100%" width="100%">
  <tr>
    <td align="middle" vAlign="center" noWrap='nowrap' background="img/leftleftCBg.gif" id="frmTitle" name="frmTitle" bgcolor="#3B78AD">
    <table width='100%' height='100%' border='0' cellpadding="0" cellspacing="0">
		<tr><td height='100%' background="img/leftleftCBg.gif" bgcolor="#3B78AD">
    <iframe  scrolling="auto" frameborder=0 id='menu' name='menu' src="<?=$left_url?>" style="HEIGHT: 100%; VISIBILITY: inherit; width:160px; Z-INDEX: 2; color:#3B78AD"></iframe>
		</td>
		</tr>
		<tr><td height="25" align="center"><a href="index.php?out=1"><font color="#FFFFFF">退出</font></a></td></tr>
	  </table></td>
    <td background="images/left_yes.gif" style="WIDTH: 9pt" title="双击关闭/打开左栏"><table width="14" height="50" border="0" cellpadding="0" cellspacing="0">
      <tr valign=TOP>
        <td style="HEIGHT: 20 pix"><font style="FONT-SIZE: 9pt; CURSOR: default; COLOR: #ffffff"> <span class="navPoint STYLE1" id="scrollup" title="向上滚动菜单" onClick="menu.scrollBy(0,-18)">5</span><br></font></td>
      </tr>
      <tr valign=middle>
        <td style="HEIGHT: 100%" onDblClick="switchSysBar()"><font style="FONT-SIZE: 9pt; CURSOR: default; COLOR: #ffffff"> <span class="navPoint STYLE1" id="switchPoint" title="双击关闭/打开左栏">3</span><br>
          功能菜单 & 双击屏幕切换 </font></td>
      </tr>
      <tr valign=bottom>
        <td style="HEIGHT: 20 pix"><font style="FONT-SIZE: 9pt; CURSOR: default; COLOR: #ffffff"> <span class="navPoint STYLE1" id="scrolldown" title="向下滚动菜单" onClick="menu.scrollBy(0,18)">6</span><br></font></td>
      </tr>
    </table></td>
    <td style="WIDTH: 100%">
    <iframe frameBorder="0"  id='frmright' name='frmright' scrolling="auto" src="<?=$right_url?>" style="HEIGHT: 100%; VISIBILITY: inherit;WIDTH:100%;Z-INDEX:1"></iframe>   </td>
  </tr>
</table>
<?php
}
else {
?>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TR>
    <TD height="571" align="middle" vAlign="center">
      <table width="681" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:120px">
  <tr>
    <td width="353" height="259" align="center" valign="bottom" background="Images/login_1.gif"><table width="90%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td align="right" valign="bottom" style="color:#05B8E4">Power by 508net Copyright 2010 </td>
      </tr>
    </table></td>
    <td width="195" background="Images/login_2.gif"><table width="190" height="106" border="0" align="center" cellpadding="2" cellspacing="0">
      <form method="post" onSubmit="return check(this);" action="index.php">
            <tr>
              <td height="50" colspan="2" align="left">&nbsp;</td>
            </tr>
            <tr>
              <td width="60" height="30" align="left">登陆名称</td>
              <td><input name="userID" type="TEXT" style="background:url(Images/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="userID"size="14"></td>
            </tr>
            <tr>
              <td height="30" align="left">登陆密码</td>
              <td><input name="password" TYPE="PASSWORD" style="background:url(Images/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="password" size="16"></td>
            </tr>
            <tr>
              <td height="30"> 验 证 码 </td>
			  <td><input name="chkCode" type="text" id="chkCode" size="6" style="background:url(Images/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" maxlength="8">
			  <img src="../inc/chk_num.php" name="img" align="absmiddle" id="img">
		      </td>
            </tr>
            <tr>
              <td height="40" colspan="2" align="center"><img src="Images/tip.gif" width="16" height="16"> &nbsp;<a href="#" name="can not see" id="test">看不清楚！</a></td>
          <tr>
              <td colspan="2" align="center"><input type="submit" name="submit" style="background:url(Images/login_5.gif) no-repeat" value=" 登  陆 "> 
			  <input type="reset" name="Submit" style="background:url(Images/login_5.gif) no-repeat" value=" 取  消 "></td>
            <tr>
              <td height="5" colspan="2"></td>
        </form>
    </table></td>
    <td width="133" background="Images/login_3.gif">&nbsp;</td>
  </tr>
  <tr>
    <td height="161" colspan="3" background="Images/login_4.gif"></td>
  </tr>
</table>
    </TD>
  </TR>
</TABLE>
<SCRIPT language=javascript>
function $(id){
return document.getElementById(id);
}
function check(){
if($("userID").value==""){
alert("登陆名称不能为空");
$("userID").focus();
return false;
}
if($("password").value==""){
alert("密码不能为空");
$("password").focus();
return false;
}
if($("chkCode").value==""){
alert("验证码不能为空");
$("chkCode").focus();
return false;
}
}
function test(img){
    var src=img.getAttribute("src");
    src=src+"?new="+Math.random(0,10);
    img.setAttribute("src",src);
}
function prepare(){
    var nav=document.getElementById("test");
    var name=nav.getAttribute("name");
    var str="can not see";
    if(name==str){
        nav.onclick=function(){
            var img=document.getElementById("img");
            test(img);
            return false;
        }
    }
}
window.onload=prepare;
</SCRIPT>
<?
}
?>
</BODY>
</HTML>
